﻿@using DualControl.CommonServices
@using DualControl.RiskPoints.Dtos

@model Abp.Application.Services.Dto.ListResultDto<RiskPointListDto>
@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@
@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

@inject ICommonService CommonService

@{
    ViewData["Title"] = "危险源管理";
}

@section scripts
    {
    <environment names="Development">
        <script src="~/view-resources/Views/HazardSources/Index.js" asp-append-version="true"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/view-resources/Views/HazardSources/Index.js" asp-append-version="true"></script>
    </environment>
}
<style>
    .table tbody tr td {
        vertical-align: middle;
    }
</style>

<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>危险源辨识(作业步骤/场所/环节/部位)
                    @*@L("HazardSource")*@
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">
                @foreach (var riskpoint in ViewBag.PageOfRiskPointListDto)
                {
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <h3 class="panel-title">
                                风险点编码：@riskpoint.Code &nbsp; 车间/班组：@CommonService.GetOrganizationUnits().SingleOrDefault(c => c.Key == riskpoint.OrganizationUnitId).Value   &nbsp; 区域/工段   @riskpoint.AreaOrSection&nbsp; 风险点名称：@riskpoint.Name
                                &nbsp;
                            </h3>
                        </div>
                      
                        <table class="table">
                         
                                <tr><th>序号</th> <th>作业目的</th>
                                   
                                    <th width="45%">危险源(作业步骤/场所/环节/部位) </th>
                                </tr>
                           
                         
                                @{ if (riskpoint.HazardSources.Count > 0)
                                    {
                                        int i = 0;
                                                   
                                                        @foreach (var hazardsource in riskpoint.HazardSources)
                                                        {
                                                            i++;
                                                            <tr>
                                                                <td>@i.</td> <td>@riskpoint.OperationPurpose</td>
                                                                <td width="50%"> @hazardsource.HazardSourceName</td>
                                                                <td>
                                                                    <span class="glyphicon glyphicon-pencil"></span>
                                                                    <button class="edit-hazardsource" data-hazardsource-id="@hazardsource.Id" data-hazardsource-jobstep="@hazardsource.HazardSourceName" data-toggle="modal" data-target="#HazardSourceEditModal">编辑</button>

                                                                </td>
                                                                <td><span class="glyphicon glyphicon-remove"></span> <button class="delete-hazardsource" data-hazardsource-id="@hazardsource.Id" data-hazardsource-name="@hazardsource.HazardSourceName">删除</button></td>
                                                            </tr>
                                                        }
                                                 
                                    }
                                    
                                }
                            <tr>            
                            <td> <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-left" data-toggle="modal" data-riskpoint-id="@riskpoint.Id" data-target="#HazardSourceCreateModal">
                                                <i class="material-icons">add</i>
                                            </button>

                                        </td>
                                        </tr>
                                      
                                </table>
                            </div>                      
                        }
                    </div>
                </div>
    </div>
</div>

@Html.PagedListPager((IPagedList)ViewBag.PageOfRiskPointListDto, page => Url.Action("Index", new { page }))

<div class="modal fade" id="HazardSourceCreateModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>危险源辨识--(作业步骤/场所/环节/部位)</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="hazardSourceCreateForm" role="form" novalidate class="form-validation">
                  <input type="hidden" name="RiskPointId" id="RiskPointId" />                    
                    @*<ul class="nav nav-tabs tab-nav-right" role="tablist">
                        <li role="presentation" class="active"><a href="#create-org-details" data-toggle="tab">新增作业步骤</a></li>
                    </ul>*@
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">作业步骤1</label>
                                        <textarea class="form-control" id="jobstep1" name="jobstep1" required minlength="3" placeholder="请输入作业步骤"></textarea>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">作业步骤2</label>
                                        <textarea class="form-control" type="text" name="jobstep2" id="jobstep2" placeholder="请输入作业步骤" ></textarea>

                                    </div>
                                </div>

                            </div>

                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">作业步骤3</label>
                                        <textarea class="form-control" type="text"id="jobstep3" name="jobstep3" placeholder="请输入作业步骤" ></textarea>


                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">作业步骤4</label>
                                        <textarea class="form-control" type="text"id="jobstep4" name="jobstep4" placeholder="请输入作业步骤" ></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="HazardSourceEditModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>编辑危险源</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="hazardSourceEditForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="Id" id="Id" />               <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">作业步骤/场所/环节/部位</label>
                                        <textarea class="form-control" type="text" id="JobStep" name="HazardSourceName" required minlength="3" placeholder="作业步骤"></textarea>
                                    </div>
                                </div>
                            </div>                          
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

</div>
